home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-23 | 2.0 KB | 111 lines | [TEXT/PJMM] |
- program TinyEdit;
-
- uses
- TransSkel, TransEdit;
-
- const
-
- aboutAlrt = 1000;
- windRsrc = 1000;
-
- { File menu item numbers }
-
- newWind = 1;
- openWind = 2;
- closeWind = 3;
- quitApp = 5;
-
- { Edit menu item numbers }
-
- undo = 1;
- cut = 3;
- copy = 4;
- paste = 5;
- clear = 6;
-
- var
-
- editWind: WindowPtr; { non-nil if edit window open }
- fileMenu: MenuHandle;
- editMenu: MenuHandle;
-
- ignore: Boolean;
-
-
- procedure Close;
- begin
- if (EWindowClose(editWind)) then
- editWind := nil;
- end;
-
-
- procedure DoAppleMenu (item: Integer);
- var
- ignore: Integer;
- begin
- ignore := SkelAlert(aboutAlrt, SkelDlogFilter(nil, true), skelPositionOnParentDevice);
- SkelRmveDlogFilter;
- end;
-
-
- procedure DoFileMenu (item: Integer);
- begin
- case item of
- newWind:
- editWind := GetNewEWindow(windRsrc, WindowPtr(-1), false);
- openWind:
- editWind := GetNewEWindow(windRsrc, WindowPtr(-1), true);
- closeWind:
- SkelClose(FrontWindow);
- quitApp:
- if (ClobberEWindows) then
- SkelStopEventLoop;
- end;
- end;
-
-
- procedure AdjustMenus;
- begin
- DisableItem(fileMenu, closeWind); { assume no window at all }
- EnableItem(editMenu, undo);
-
- if (FrontWindow <> nil) then
- begin
- EnableItem(fileMenu, closeWind);
- if (IsEWindow(FrontWindow)) then { the edit window's in front }
- DisableItem(editMenu, undo);
- end;
- if (editWind = nil) then
- begin
- EnableItem(fileMenu, newWind);
- EnableItem(fileMenu, openWind);
- end
- else
- begin
- DisableItem(fileMenu, newWind);
- DisableItem(fileMenu, openWind);
- end;
- end;
-
-
- begin
- editWind := nil;
-
- SkelInit(nil);
- SkelApple('About TinyEdit…', @DoAppleMenu);
- fileMenu := NewMenu(1000, 'File');
- AppendMenu(fileMenu, 'New/N;Open…/O;(Close/W;(-;Quit/Q');
- ignore := SkelMenu(fileMenu, @DoFileMenu, nil, false, true);
-
- editMenu := NewMenu(1001, 'Edit');
- AppendMenu(editMenu, 'Undo/Z;(-;Cut/X;Copy/C;Paste/V;Clear');
- ignore := SkelMenu(editMenu, @EWindowEditOp, nil, false, false);
-
- DrawMenuBar;
- SkelSetMenuHook(@AdjustMenus);
-
- SetEWindowProcs(nil, nil, nil, @Close);
-
- SkelEventLoop;
- SkelCleanup;
- end.